package leetcode;

public class Test2035 {

    public static void main(String[] args) {
        ListNode head = new ListNode(2);
        ListNode p1 = new ListNode(3);
        head.next=p1;
        ListNode p2 = new ListNode(4);
        p1.next=p2;



        Test2035 test2035 = new Test2035();
        test2035.reverseList(head);

    }

    public ListNode reverseList(ListNode head) {
        ListNode prev = null;
        ListNode curr = head;
        while (curr != null) {
            ListNode next = curr.next;
            curr.next = prev;
            prev = curr;
            curr = next;
        }
        return prev;
    }
}
